package com.lovo.classinfo;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.Border;
import javax.swing.border.EtchedBorder;

import com.lovo.netCRM.component.LovoButton;
import com.lovo.netCRM.component.LovoComboBox;
import com.lovo.netCRM.component.LovoCutPage;
import com.lovo.netCRM.component.LovoList;
import com.lovo.netCRM.component.LovoTable;
import com.lovo.netCRM.component.LovoTitleLabel;
import com.lovo.netCRM.component.LovoTitlePanel;
import com.lovo.netCRM.component.LovoTxt;


/**
 * 班级管理主面板
 * @author 白德柯
 *
 */
public class ClassPanel extends JPanel{

	/**班级表格组件*/
	private LovoTable classTable;
	/**窗体组件*/
	private JFrame jf;
	
	/**学校列表*/
	private LovoList schoolList;

	/**分页对象*/
	private LovoCutPage cutPage;
	public ClassPanel(JFrame jf){
		this.jf = jf;
		this.setLayout(null);
		this.init();
	}
	/**
	 * 初始化
	 *
	 */
	private void init() {
		new LovoTitleLabel("班 级 管 理",this);
		this.initTable();
		this.initList();
		this.initButton();
		this.initData();
	}
	/**
	 * 初始化数据
	 */
	public void initData(){
		this.updateTable(1);
	}
	/**
	 * 初始化按钮
	 *
	 */
	private void initButton() {
		LovoButton addButton = new LovoButton(50,460,"添加班级","image/add.png",this);
		
		addButton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				new ClassAddDialog(jf, 0, ClassPanel.this);
			}
		});
		
		LovoButton updateButton = new LovoButton(250,460,"修改班级","image/update.png",this);
		
		updateButton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				new ClassUpdateDialog(jf, 0, ClassPanel.this);
			}
		});
		
	

	}
	

	
	//-------------------------------------------------
	/**
	 * 初始化表格
	 *
	 */
	private void initTable() {
		classTable = new LovoTable(this,
				new String[]{"班级名称","开班时间","班级人数","带班老师"},
				new String[]{},//班级实体属性名数组 new String[]{"name","sex"}
				"");//主键属性名
		classTable.setSizeAndLocation(220, 90, 500, 300);
		// 分页
		cutPage = new LovoCutPage(220,400,this) {
			@Override
			public void clickEvent(int arg0) {
				
			}
		};
		
	}
	/**
	 * 初始化列表
	 */
	private void initList() {
		schoolList = new LovoList(20, 90, 195, 300, new ArrayList(), this);
		schoolList.setBorder(BorderFactory.createEtchedBorder());
	}
	/**
	 * 更新表格数据
	 */
	private void updateTable(int page){
		//更新表格
		classTable.updateLovoTable(null);
	}
	

}
